package com.example.kotlindemo

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.kotlindemo.basic.state
import com.example.kotlindemo.pages.NewWorkActivity
import com.example.kotlindemo.pages.TabLayoutActivity
import com.example.kotlindemo.pages.TodoListActivity
import com.example.kotlindemo.pages.ViewPagerTabActivity

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // 获取系统栏的高度，设置 View 的内边距
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        // state()

        // 获取按钮
        val buttonTabLayout: Button = findViewById(R.id.go_tab_layout)
        val buttonTodoList: Button = findViewById(R.id.go_todolist)
        val buttonNetwork: Button = findViewById(R.id.go_network)
        val buttonViewTab: Button = findViewById(R.id.go_view_pager_tab)

        // 为按钮设置点击事件
        buttonTabLayout.setOnClickListener {
            val intent = Intent(this, TabLayoutActivity::class.java)
            startActivity(intent)
        }

        buttonTodoList.setOnClickListener {
            val intent = Intent(this, TodoListActivity::class.java)
            startActivity(intent)
        }

        buttonNetwork.setOnClickListener {
            val intent = Intent(this, NewWorkActivity::class.java)
            startActivity(intent)
        }

        buttonViewTab.setOnClickListener {
            val intent = Intent(this,ViewPagerTabActivity::class.java)
            startActivity(intent)
        }



    }
}
